<!DOCTYPE HTML>
<html>
<head>
<include file="Include:meta" />
<title>内部专家库-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	#upModal label{ line-height: 30px; display: block; margin-top: 10px; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">内部专家库</div>
		<div class="right">
			<div class="input-group left w250">
		    	<input type="text" id="keyword" value="{$keyword}" class="form-control" placeholder="按姓名/附件搜索" autocomplete="off">
	    		<span class="input-group-btn">
	        		<button class="btn found_btn" type="button">搜索</button>
		    	</span>
		    </div>
			<if condition="get_permission('RC',1,1)">
				<a href="__APP__/Index/label_administration/type/5/classif/11/types/内部专家库/sz/1" class="btn left ml5" target="_blank">设置</a>
			</if>
			<if condition="is_permission('RC',NULL,1)">
				<a href="__APP__/Index/talent_add" class="btn left ml5">添加</a>
			</if>
		</div>
	</div>
	<div id="content">
		<if condition="!get_permission('RC',2) or $screen neq null">
		<div class="filter">
			<if condition="!get_permission('RC',2)">
			<div class="filter-item">
				<div class="filter-title">所属中心：</div>
				<ul class="filter-order">
					<li <if condition="$center_id eq -10">class="current"</if>>
						<a href="__APP__/Index/talent_list/keyword/{$keyword}/center_id/-10/ids/{$ids}/action1/{$action1}/action2/{$action2}/action3/{$action3}">全部</a>
					</li>
					<foreach name="center_type" item="vo">
					<li <if condition="$center_id eq $vo['id']">class="current"</if>>
						<a href="__APP__/Index/talent_list/keyword/{$keyword}/center_id/{$vo['id']}/ids/{$ids}/action1/{$action1}/action2/{$action2}/action3/{$action3}">{$vo['first_name']}<if condition="$sz_status['name4'] eq 1"><if condition="($vo['times'] neq 0) and ($vo['times'] neq -1)">({$vo['times']})</if></if></a>
					</li>
					</foreach>
				</ul>
			</div>
			</if>
			<if condition="$screen neq null">
				<foreach name="screen" item="vo" key="k">
					<div <if condition="($k gt 2 and !get_permission('RC',2)) or ($k gt 3 and get_permission('RC',2))">class="filter-item hide"<else/>class="filter-item"</if>>
						<div class="filter-title">{$vo['first_name']}：</div>
						<ul class="filter-order filter-orders">
							<volist name="vo['second']" id="wo">
								<li <if condition="$wo['id'] eq $vo['tid']">class="current"</if>>
									<a href="javascript:;" tid="{$wo['id']}">{$wo['second_name']}<if condition="$sz_status['name4'] eq 1"><if condition="($wo['times'] neq 0) and ($wo['times'] neq -1)">({$wo['times']})</if></if></a>
								</li>
							</volist>
						</ul>
					</div>
				</foreach>
				<if condition="($screen_num gt 4 and get_permission('RC',2)) or ($screen_num gt 3 and !get_permission('RC',2))">
					<div class="filter-more"><span class="more">更多筛选<i class="fa fa-angle-down"></i></span></div>
				</if>
			</if>
		</div>
		</if>
		<div class="">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td>姓名</td>
					<td>手机号</td>
					<td>员工号</td>
					<foreach name="screen" item="vo">
					<td>{$vo['first_name']}</td>
					</foreach>
					<td>附件</td>
					<td width="140">添加人(日期)</td>
					<td width="74">管理</td>
				</tr>
				<if condition="$result eq NULL">
				<tr><td class='text-center' <if condition="is_permission('RC',NULL,1) or $is_self eq 1">colspan="{$screen_num+6}"<else/>colspan="{$screen_num+6}"</if>>暂无相关内容</td></tr>
				</if>
				<foreach name="result" item="vo">
					<tr>
						<td><a href="__APP__/Index/library_detail/id/{$vo['id']}/classif/11/type/{$vo['type']}">{$vo['username']}</a><if condition="$vo['section'] eq 1"><i style="color:#d9534f" class="glyphicon glyphicon-arrow-up ml5"></i></if></td>
						<td>{$vo['mobilephone']}</td>
						<td>{$vo['empl_id']}</td>
						<foreach name="screen" item="uo" key="k">
						<td>{$vo['types'][$k]}</td>
						</foreach>
						<td>
							<if condition="$vo['file_url'] neq NULL">{$vo['file_name']}
							<a href="{$vo['file_url']}" did="{$vo['id']}" target="_blank" data-toggle="tooltip" data-placement="left" title="下载" class="ml5"><i class="glyphicon glyphicon-download-alt"></i></a>
							</if>
						</td>
						<td>{$vo['add_user']}({$vo['add_date']|substr=0,10})</td>
						<td class="nowrap">
							<if condition="((get_permission('RC',NULL,3)) and ($vo['add_uid'] eq $login_id)) or (get_permission('RC',NULL,2) and strstr($vo['center_id'],$login_center_id)) or (get_permission('RC',NULL,1))">
								<a href="__APP__/Index/talent_edit/id/{$vo['id']}/keyword/{$keyword}/center_id/{$center_id}/ids/{$ids}/action1/{$action1}/action2/{$action2}/action3/{$action3}" data-toggle="tooltip" data-placement="left" title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
							<elseif condition="$vo['name'] eq $login_id" />
								<a href="javascript:;" class="operate" data-toggle="tooltip" data-placement="left" title="编辑" mid="{$vo['id']}"><i class="glyphicon glyphicon-edit"></i></a>
							</if>
							<span class="btn_menu"><i class="fa fa-th"></i>
								<em>
									<if condition="((get_permission('RC',NULL,3)) and ($vo['add_uid'] eq $login_id)) or (get_permission('RC',NULL,2) and strstr($vo['center_id'],$login_center_id)) or (get_permission('RC',NULL,1))">
										<a href="javascript:;" zid="{$vo['id']}" class="delete"><i class="glyphicon glyphicon-trash"></i>删除</a>
									</if>
									<if condition="$vo['collection'] eq NULL">
										<a href="javascript:;" zid="{$vo['id']}" class="collection"><i class="glyphicon glyphicon-star-empty"></i>收藏</a>
									<else/>
										<a href="javascript:;" zid="{$vo['id']}" class="collection"><i class="glyphicon glyphicon-star"></i>取消收藏</a>
									</if>
									<if condition="get_permission('RC',1,1)">
										<if condition="$sz_status['name2'] eq 1">
											<if condition="$vo['section'] eq 1 or $vo['home'] eq 1">
												<a href="javascript:;" zid="{$vo['id']}" action="zd_down" class="zd_down"><i class="glyphicon glyphicon-arrow-down"></i>取消置顶</a>
											<else/>
												<a href="javascript:;" zid="{$vo['id']}" class="zd_top"><i class="glyphicon glyphicon-arrow-up"></i>置顶</a>
											</if>
										</if>
									</if>
									<if condition="$sz_status['name3'] eq 1">
										<a href="javascript:;" zid="{$vo['id']}" shall="{$shall}" class="fx_top"><i class="fa fa-share"></i>分享</a>
									</if>
								</em>
							</span>
							<input type="hidden" value="{$vo['share_uids']}" name="share_hid">
						</td>
					</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!--对话框-->
<div class="modal fade" id="myModal-operate">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>编辑从业经验</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<table class="table table-bordered">
					<tr>
						<td class="text-right"><strong>从业经验</strong></td>
						<td>
							<textarea name="remark" class="form-control w300 reason left" autocomplete="off"></textarea>
							<span class="error-item left">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--联系人详情-->
<div id="upModal" class="modal hide fade">
	<div class="modal-dialog w500">
		<div class="modal-content">
			<div class="modal-header">
				<h4 id="myModalLabel">置顶</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				您确定要置顶吗？
				<label class="checkbox-inline mr5">
					<input type="checkbox" name="" value="XM" autocomplete="off">是否同步到首页
				</label>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-confirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--联系人详情-->
<div id="detailModal" class="modal hide fade">
	<div class="modal-dialog w500">
		<div class="modal-content">
			<div class="modal-header">
				<h4 id="myModalLabel">阅读详情</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body"></div>
		</div>
	</div>
</div>
<!--分享-->
<div class="modal fade" id="selectuser-modal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>选择用户</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<input type="hidden" name="fx_hide" zid="">
				<foreach name="user_list" item="do">
					<div class="department">
						<label><if condition="$shall eq 1"><input class="department-checkbox" type="checkbox" autocomplete="off" /></if>{$do['name']}</label>
					</div>
					<ul>
						<foreach name="do['user']" item="uo">
							<li>
								<label><input class="user-checkbox active" type="checkbox" value="{$uo['id']}" autocomplete="off" />{$uo['username']}</label>
							</li>
						</foreach>
					</ul>
				</foreach>
			</div>
			<div class="modal-footer">
				<if condition="$shall eq 1"><button type="button" class="btn user-all">全选</button></if><button type="button" class="btn user-affirm">确认</button><button type="button" class="btn btn-default user-cancel" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	//联系人详情
	$(".detail").on("click",function(){
		var mid = $(this).attr("mid");
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"id":mid,"action":"detail"},
			url:"__APP__/Index/library_ajax",
			success:function(data){
				var html = "<table class='table table-bordered'>";
					html += "<tr  class='table-header'><td>阅读人</td><td>阅读时间</td></tr>";
				for(var i=0;i<data.length;i++){
					html += "<tr>";
					html += "<td>"+data[i].add_user+"</td>";
					html += "<td>"+data[i].add_date+"</td>";
					html += "</tr>";
				}
				html+="</table>";
				$("#detailModal").find(".modal-body").html(html).end().modal();
			}
		});
	});
	//搜索
	$(".found_btn").keywordSearch("__APP__/Index/talent_list/keyword/$keyword/center_id/{$center_id}/ids/{$ids}/action1/{$action1}/action2/{$action2}/action3/{$action3}");
	
	//分享
	$(".fx_top").click(function(){
		$("#selectuser-modal").find('input').removeAttr("checked").end().modal("show");
		var zid = $(this).attr('zid'),
			shall = $(this).attr('shall');
		$("[name='fx_hide']").attr('zid',zid);
		if(shall!=1){
			$("#selectuser-modal").find('input').click(function(){
				$(this).toggleClass('active');
				if($("#selectuser-modal").find('input:checked').length==5){
					$("#selectuser-modal").find('.active').attr('disabled',true);
				}else{
					$("#selectuser-modal").find('.active').attr('disabled',false);
				}
			})
		}
		var $checkeduser = $(this).parents('.btn_menu').siblings("[name='share_hid']").val();
		if($checkeduser!=""){
			$checkeduser = $checkeduser.split(",");
			$('#selectuser-modal').find(".user-checkbox").each(function(){
				var $user = $(this).val();
				for(var i=0;i<$checkeduser.length;i++){
					if($user==$checkeduser[i]){
						$(this).prop("checked",true);
					}
				}
			});
		}
	});
	$('.user-affirm').click(function(){
		if($("#selectuser-modal").find('input:checked').length<1){
			$("body").append("<div class='success-defeated hide'>至少选择一位用户</div>");
		    var defeated = $(".success-defeated"),
		    	t = -defeated.outerHeight()/2,
		        l = -defeated.outerWidth()/2;
		   	defeated.css({"margin-top":t,"margin-left":l}).slideDown();
		    setTimeout(function(){
		    	defeated.remove();
		    },2000);
		}else{
			var uids = "",
				zid = $("[name='fx_hide']").attr('zid');
			$("#selectuser-modal").find(".user-checkbox").each(function(){
				if($(this).prop("checked")){
					uids += $(this).val()+",";
				}
			});
			uids = uids.replace(/\,$/,"");
			$("#selectuser-modal").hide();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"share_uids":uids,"id":zid,"action":"fx_top","folder_type":"2"},
				url:"__APP__/Index/library_ajax",
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			})
		}
	})

	//部门全选
	$('body').on("click",".department-checkbox",function(){
		var $ul = $(this).parents(".department").next("ul");
		if($(this).prop("checked")){
			$ul.find(".user-checkbox:enabled").prop("checked",true);
		}else{
			$ul.find(".user-checkbox:enabled").prop("checked",false);
			$usermodal.find(".all-checkbox").prop("checked",false);
		}
	});
	//全选
	$('body').on('click','.user-all',function(){
		$(this).addClass('user-active');
		$(this).html("取消全选");
		$('.modal-body').find('.user-checkbox').prop("checked",true);
	})
	$('body').on('click','.user-active',function(){
		$(this).removeClass('user-active');
		$(this).html("全选");
		$('.modal-body').find('.user-checkbox').removeAttr("checked");
	})
	
	//删除列表
	$(".delete").ajaxModal({"title_text":"确认提示框","body_text":"您确定要删除吗？","url":"__APP__/Index/library_ajax","data":{"id":"zid","action":"action"}});

	//取消置顶
	$(".zd_down").ajaxModal({"title_text":"确认提示框","body_text":"您确定要取消置顶吗？","url":"__APP__/Index/library_ajax","data":{"id":"zid","action":"action"}});

	//取消分享
	$(".fx_down").ajaxModal({"title_text":"确认提示框","body_text":"您确定要取消分享吗？","url":"__APP__/Index/library_ajax","data":{"id":"zid","action":"action"}});

	//置顶
	$('.zd_top').click(function(){
		var zid = $(this).attr('zid');
		$("#upModal").find('input').attr('zid',zid).end().modal();
		$("#upModal").find('input').removeAttr("checked");
	})
	$("#upModal .btn-confirm").click(function(){
		var zid = $("#upModal").find('input').attr('zid');
		if($("#upModal").find('input:checked').length==1){
			var check = 1;
		}
		$("#upModal").hide();
		$.ajax({
			cache:false,
			type:"POST",
			dataType:"json",
			url:"__APP__/Index/library_ajax",
			data:{"id":zid,"home":check,"action":"zd_top"},
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	})
	//分类
	$(".filter-orders").find("a").click(function(){
		var ids = "";
		$(this).parents("ul").find("li").removeAttr("class");
		$(this).parent("li").attr("class","current");
		$(".filter-orders").find("li").each(function(){
			if($(this).attr("class") == "current"){
				ids += $(this).find("a").attr("tid")+",";
			}
		});
		ids = ids.replace(/\,$/g,"");
		window.location.href = "__APP__/Index/talent_list/keyword/{$keyword}/center_id/{$center_id}/ids/"+ids;
	});
	
	//操作
	$(".operate").on("click",function(){
		var mid = $(this).attr("mid");
		$("#myModal-operate").modal().find(".btn-affirm").attr({"mid":mid});
		$.ajax({
			type:"POST",
			asnyc:false,
			dataType:"json",
			data:{"id":mid,"action":"talent_detail"},
			url:"__APP__/Index/library_ajax",
			success:function(data){
				$("[name='remark']").val(data.remark);
			}
		});
	});

	//确认操作
	$("#myModal-operate").find(".btn-affirm").on("click",function(){
		var tag = true,
			modal = $("#myModal-operate");

		if(tag){
			var mid = $(this).attr("mid"),
				remark = modal.find(".reason").val();
			modal.hide();
			$.ajax({
				type:"POST",
				asnyc:false,
				dataType:"json",
				data:{"id":mid,"remark":remark,"action":"talent_edit"},
				url:"__APP__/Index/library_ajax",
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	
	//取消错误提示
	$("#myModal-operate").find(".type").on("click",function(){
		$(this).parent("label").nextAll(".error-item").hide();
	});
	$("#myModal-operate").find(".reason,.stop_date").on("focus",function(){
		$(this).next(".error-item").hide();
	});
	
	//取消操作
	$("#myModal-operate").on('hidden.bs.modal',function(){
		$(this).find(".error-item").hide();
		$(this).find(":radio").prop("checked",false);
		$(this).find(".reason,.stop_date").val("");
	});
	//收藏
	$('.collection').on("click",function(){
		var $zid = $(this).attr("zid");
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"id":$zid,"action":"collection"},
			url:"__APP__/Index/library_ajax",
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
});
</script>
</body>
</html>